import 'package:backend.core/core/domain/entities/api/app_store/api_app_store_one_time_purchased_item.dart';
import 'package:backend.core/core/domain/entities/api/app_store/api_app_store_purchased_item.dart';
import 'package:backend.core/core/domain/entities/api/app_store/api_app_store_purchased_subscription.dart';
import 'package:backend.purchases/infrastructure/dtos/api/app_store/api_app_store_one_time_purchased_item_dto.dart';
import 'package:backend.purchases/infrastructure/dtos/api/app_store/api_app_store_purchased_item_dto.dart';
import 'package:backend.purchases/infrastructure/dtos/api/app_store/api_app_store_purchased_subscription_dto.dart';

class ApiAppStorePurchasedItemDtoFactory {
  const ApiAppStorePurchasedItemDtoFactory._internal();

  static const _instance = ApiAppStorePurchasedItemDtoFactory._internal();

  factory ApiAppStorePurchasedItemDtoFactory() {
    return _instance;
  }

  ApiAppStorePurchasedItemDto fromEntity(ApiAppStorePurchasedItem purchasedItem) {
    if (purchasedItem is ApiAppStoreOneTimePurchasedItem) {
      return ApiAppStoreOneTimePurchasedItemDto.fromEntity(purchasedItem);
    }

    if (purchasedItem is ApiAppStorePurchasedSubscription) {
      return ApiAppStorePurchasedSubscriptionDto.fromEntity(purchasedItem);
    }

    throw UnimplementedError();
  }
}
